package cn.closeli.qrencode;

import android.graphics.Bitmap;
import android.util.Log;

public class QRCodeWriter {
    private static final String TAG = QRCodeWriter.class.getSimpleName();

    public Bitmap createQRCodeBitmap(String content, int width) {
        int qrCodeWidth = nativeInit(content);
        Log.e(TAG, "QRCode width is: " + qrCodeWidth);
        Bitmap qrcode = Bitmap.createBitmap(qrCodeWidth, qrCodeWidth, Bitmap.Config.ARGB_8888);
//        nativeCreateQRCode(qrcode);
        nativeCreateQRCodeBitmap(qrcode);
        Bitmap scaledBitmap = Bitmap.createScaledBitmap(qrcode, width, width, false);

        return scaledBitmap;
    }

    public native int nativeInit(String content);
    public native String nativeStringFromJni();
    public native void nativeGenColorStripes(Bitmap bitmap);
    public native void nativeCreateQRCodeBitmap(Bitmap bitmap);
    public native void nativeCreateQRCode(Bitmap bitmap);
    public native void nativeFinalize();

    static {
        System.loadLibrary("qrencode");
    }
}
